﻿/*
 * Copyright 2011 Edward L. Stauff.                     Contact: <EdStauff@gmail.com>.
 * 
 * This file, "CmdLineParam.cs", is part of the "Stauffware.Common.Console" class 
 * library.  "Stauffware.Common" is free software: you can redistribute it and/or 
 * modify it under the terms of the GNU Lesser Public License as published by the 
 * Free Software Foundation, either version 3 of the License, or (at your option) 
 * any later version.
 * 
 * "Stauffware.Common" is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser Public License for more 
 * details.
 * 
 * You should have received a copy of the GNU Lesser Public License along with 
 * "Stauffware.Common".  If not, see <http://www.gnu.org/licenses/>.
 */

using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Configuration;
using Stauffware.Common.Core;

namespace Stauffware.Common.Console
{
	/// <summary>
	/// Specifies how many values a command-line parameter can take.
	/// </summary>
	public enum Arity
	{
		/// <summary> The command-line parameter takes no values. </summary>
		None,

		/// <summary> The command-line parameter takes a single value. </summary>
		Single,

		/// <summary> The command-line parameter takes a list of values. </summary>
		Multiple
	}

	//#################################################################################
	/// <summary>
	/// Represents one command-line parameter.
	/// </summary>

	public interface ICmdLineParam
	{
		/// <summary>
		/// Gets the name of the parameter.
		/// </summary>
		string Name { get; }

		/// <summary>
		/// If > 1, this specifies the position (relative to other positional 
		/// parameters) of this parameter's value, if its value is provided 
		/// without a name.  If Position = 0, then the parameter cannot be
		/// used as a positional parameter (that is, without its name).
		/// </summary>
		/// <remarks>
		/// Named parameters and their values are not counted when determining
		/// position.  The set of all positional parameters must have unique 
		/// Position values starting at 1 and monotonically increasing.
		/// </remarks>
		int Position { get; }

		/// <summary>
		/// Gets whether this parameter can be positional; that is, can be
		/// used without its name.
		/// </summary>
		bool CanBePositional { get; }

		/// <summary>
		/// Gets whether this parameter is a switch; that is, its name starts
		/// with the switch character.
		/// </summary>
		bool IsSwitch { get; }

		/// <summary>
		/// Gets or sets the help (documentation) for this parameter.
		/// </summary>
		string Help { get; set; }
	
		/// <summary>
		/// Gets whether this parameter is required.
		/// </summary>
		bool IsRequired { get; }

		/// <summary>
		/// Gets the number of values that the parameter can take: 0, 1, or N.
		/// (This is implied by the type of the target field or property.)
		/// </summary>
		Arity Arity { get; }

		/// <summary>
		/// Gets the full name of the parameter (including its group name, if any).
		/// </summary>
		string FullName { get; }

		/// <summary>
		/// Gets the type for the value(s) of this parameter, or null if it takes no values.
		/// If the target field or property is a List, then ValueType is the type of
		/// the list members, not the entire list.
		/// </summary>
		Type EffectiveValueType { get; }

		/// <summary>
		/// Gets whether the parameter been found in the parsed command-line parameters.
		/// </summary>
		bool Found { get; }
	}

}
